﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace CPA
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public partial class Game1 : Microsoft.Xna.Framework.Game
    {
        Texture2D[] menuGraphics = new Texture2D[1];
        SpriteFont[] menuFonts = new SpriteFont[2];
        SpriteFont font;

        fmv_02_startmenu menu;
        fmv_03_intro FmvIntro;
        fmv_04_scatter fmv04;

        Texture2D lv01BackDrop;
        Texture2D[] lv01TileSet = new Texture2D[7];
        Texture2D lv01Map;

        Texture2D lv02Map;

        Texture2D textbox, labTiles;
        Texture2D[] war, famine = new Texture2D[16], death = new Texture2D[16], chaos, fromage = new Texture2D[16], hero = new Texture2D[16];
        
        level level01, level02;

        Texture2D HealthBarBG, HealthBarFG;

        SoundEffect deathSFX;
        Song opening;

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // ***** GENERAL *****
            textbox = Content.Load<Texture2D>("textbox");
            labTiles = Content.Load<Texture2D>("tiles/lab/labfloor-t");
            font = Content.Load<SpriteFont>("font");

            //******** SOUNDS *********
            deathSFX = Content.Load<SoundEffect>("sfx/death");
            opening = Content.Load<Song>("sfx/opening");
            

            // ********* Health Bar **********
            HealthBarBG = Content.Load<Texture2D>("HealthBarBG");
            HealthBarFG = Content.Load<Texture2D>("HealthBarFG");

            // ***** MENU ASSETS *****
            menuGraphics[0] = Content.Load<Texture2D>("startMenuBg");
            menuFonts[0] = Content.Load<SpriteFont>("startMenuNormal");
            menuFonts[1] = Content.Load<SpriteFont>("startMenuSelected");

            menu = new fmv_02_startmenu(spriteBatch, menuGraphics, menuFonts, opening);

            // ***** FROMAGE *****
            fromage[0] = Content.Load<Texture2D>("characters/fromage/fromage-talk");
            fromage[1] = Content.Load<Texture2D>("characters/fromage/fromage-talk-2");
            fromage[2] = Content.Load<Texture2D>("characters/fromage/fromage-walk-1");
            fromage[3] = Content.Load<Texture2D>("characters/fromage/fromage-walk-2");
            fromage[4] = Content.Load<Texture2D>("characters/fromage/fromage-walk-3");
            fromage[5] = Content.Load<Texture2D>("characters/fromage/fromage-walk-4");
            fromage[6] = Content.Load<Texture2D>("characters/fromage/fromage-walk-5");
            fromage[7] = Content.Load<Texture2D>("characters/fromage/fromage-walk-6");
            fromage[8] = Content.Load<Texture2D>("characters/fromage/fromage-walk-7");
            fromage[9] = Content.Load<Texture2D>("characters/fromage/fromage-walk-8");
            fromage[10] = Content.Load<Texture2D>("characters/fromage/attack-left");
            fromage[11] = Content.Load<Texture2D>("characters/fromage/attack-right");
            fromage[12] = Content.Load<Texture2D>("characters/fromage/fromage-talk");
            fromage[13] = Content.Load<Texture2D>("characters/fromage/fromage-talk");
            fromage[14] = Content.Load<Texture2D>("characters/fromage/fromage-talk");

            character DrFromage = new character(fromage, spriteBatch, "Dr. Fromage", textbox, 0, 0, font);

            // ***** FAMINE *****
            famine[0] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[1] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[2] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[3] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[4] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[5] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[6] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[7] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[8] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[9] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[10] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[11] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[12] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[13] = Content.Load<Texture2D>("characters/famine/famine-talk");
            famine[14] = Content.Load<Texture2D>("characters/famine/famine-talk");

            character Famine = new character(famine, spriteBatch, "Famine", textbox, 0, 0, font);

            // ***** DEATH *****
            death[0] = Content.Load<Texture2D>("characters/death/death-talk");
            death[1] = Content.Load<Texture2D>("characters/death/death-talk");
            death[2] = Content.Load<Texture2D>("characters/death/death-talk");
            death[3] = Content.Load<Texture2D>("characters/death/death-talk");
            death[4] = Content.Load<Texture2D>("characters/death/death-talk");
            death[5] = Content.Load<Texture2D>("characters/death/death-talk");
            death[6] = Content.Load<Texture2D>("characters/death/death-talk");
            death[7] = Content.Load<Texture2D>("characters/death/death-talk");
            death[8] = Content.Load<Texture2D>("characters/death/death-talk");
            death[9] = Content.Load<Texture2D>("characters/death/death-talk");
            death[10] = Content.Load<Texture2D>("characters/death/death-talk");
            death[11] = Content.Load<Texture2D>("characters/death/death-talk");
            death[12] = Content.Load<Texture2D>("characters/death/death-talk");
            death[13] = Content.Load<Texture2D>("characters/death/death-talk");
            death[14] = Content.Load<Texture2D>("characters/death/death-talk");

            character Death = new character(death, spriteBatch, "Death", textbox, 0, 0, font);

            // ***** HERO *****
            hero[0] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[1] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[2] = Content.Load<Texture2D>("characters/hero/hero-walk-5");
            hero[3] = Content.Load<Texture2D>("characters/hero/hero-walk-6");
            hero[4] = Content.Load<Texture2D>("characters/hero/hero-walk-7");
            hero[5] = Content.Load<Texture2D>("characters/hero/hero-walk-8");
            hero[6] = Content.Load<Texture2D>("characters/hero/hero-walk-1");
            hero[7] = Content.Load<Texture2D>("characters/hero/hero-walk-2");
            hero[8] = Content.Load<Texture2D>("characters/hero/hero-walk-3");
            hero[9] = Content.Load<Texture2D>("characters/hero/hero-walk-4");
            hero[10] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[11] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[12] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[13] = Content.Load<Texture2D>("characters/hero/hero-talk");
            hero[14] = Content.Load<Texture2D>("characters/hero/hero-talk");

            character Hero = new character(hero, spriteBatch, "[Hero]", textbox, 0,0, font);

            // ***** LEVEL ONE *****
            lv01Map = Content.Load<Texture2D>("maps/level02");
            lv01BackDrop = Content.Load<Texture2D>("backdrops/level01");
            lv01TileSet[0] = Content.Load<Texture2D>("tiles/plain/water");
            lv01TileSet[1] = Content.Load<Texture2D>("tiles/plain/water2");
            lv01TileSet[2] = Content.Load<Texture2D>("tiles/plain/grass");
            lv01TileSet[3] = Content.Load<Texture2D>("tiles/plain/dirt");
            lv01TileSet[4] = Content.Load<Texture2D>("tiles/plain/sand");
            lv01TileSet[5] = Content.Load<Texture2D>("tiles/plain/stone");
            lv01TileSet[6] = Content.Load<Texture2D>("tiles/plain/brick");
            List<character> lv01Chars = new List<character>();

            lv01Chars.Add(Hero);

            level01 = new level(lv01Map, lv01TileSet, lv01Chars, lv01BackDrop, HealthBarBG, HealthBarFG, font, spriteBatch, deathSFX);
            level01.set_state(GameState.Level01);



            //****** LEVEL TWO ********
            lv02Map = Content.Load<Texture2D>("maps/level01");

            Texture2D gy = Content.Load<Texture2D>("backdrops/graveyard");

            List<character> fmvIntroChars = new List<character>();
            fmvIntroChars.Add(DrFromage);
            fmvIntroChars.Add(Famine);
            fmvIntroChars.Add(Death);
            FmvIntro = new fmv_03_intro(fmvIntroChars, gy, spriteBatch);

            List<character> fmv04Chars = new List<character>();
            fmv04Chars.Add(Death);
            fmv04Chars.Add(Famine);
            fmv04 = new fmv_04_scatter(fmv04Chars, gy, spriteBatch);

           /* war = Content.Load<Texture2D>("characters/war/war");
            famine = Content.Load<Texture2D>("characters/famine/famine");
            death = Content.Load<Texture2D>("characters/death/death");
            chaos = Content.Load<Texture2D>("characters/chaos/chaos");
            fromage = Content.Load<Texture2D>("characters/fromage/fromage-standing");*/
        }

    }
}
